<template>
  <div style="width: 100%; height: 100%; background-color: #f3f5f9">
    <div class="function-area">
      <!-- 返回按钮和标题 -->
      <div class="header">
        <button class="back-btn" @click="goBack">
          <img class="arrow" src="@/assets/xiangmujindu/arrow_right.png" style="width: 22px;margin-left: 10px; transform: rotate(180deg);" /></button>
        <h3>设置</h3>
      </div>
    </div>
    <!-- 主容器 -->
    <div class="container">
      <div class="row" @click="goToPage('genghuanshoujihao')">
        <span class="label">手机号</span>
        <div class="right">
          <span class="value">132****7654</span>
          <img class="icon" src="@/assets/xiangmujindu/arrow_right.png" alt="右箭头" />
        </div>
      </div>
      <div class="divider"></div>

      <div class="row" @click="goToPage('xiugaimima')">
        <span class="label">修改密码</span>
        <div class="right">
          <img class="icon" src="@/assets/xiangmujindu/arrow_right.png" alt="右箭头" />
        </div>
      </div>
      <div class="divider"></div>
      <div class="row" @click="goToPage('bangdingyouxiang')">
        <span class="label">绑定邮箱</span>
        <div class="right">
          <img class="icon" src="@/assets/xiangmujindu/arrow_right.png" alt="右箭头" />
        </div>
      </div>
      <div class="divider"></div>
      <div class="row" @click="goToPage('guanyuwomen')">
        <span class="label">关于我们</span>
        <div class="right">
          <img class="icon" src="@/assets/xiangmujindu/arrow_right.png" alt="右箭头" />
        </div>
      </div>
    </div>

    <!-- 主容器 -->
    <div class="container">
      <div class="row" @click.stop="toQd('zx')">
        <span class="label">注销账户</span>
        <div class="right">
          <img class="icon" src="@/assets/xiangmujindu/arrow_right.png" alt="右箭头" />
        </div>
      </div>
      <div class="divider"></div>

      <div class="row">
        <span class="label">用户隐私协议</span>
        <div class="right">
          <img
            class="icon"
            src="@/assets/xiangmujindu/arrow_qyxi_right@3x.png"
            alt="右箭头"
          />
        </div>
      </div>
      <div class="divider"></div>
      <div class="row">
        <span class="label">服务协议</span>
        <div class="right">
          <img
            class="icon"
            src="@/assets/xiangmujindu/arrow_qyxi_right@3x.png"
            alt="右箭头"
          />
        </div>
      </div>
      <div class="divider"></div>
      <div class="row">
        <span class="label">当前版本</span>
        <div class="right">
          <span class="value">V3.2.5</span>
        </div>
      </div>
    </div>
    <!-- 区域2 -->
    <div class="logoff-area">
      <button class="logoff-button" @click.stop="toQd('tc')">退出登录</button>
    </div>


    <!-- 退出弹窗 -->
    <div v-if="qdSureVisi" style="position: fixed;top: 0;left: 0; width: 100vw;height: 100vh;background-color: rgba(0, 0, 0, 0.5);">
      <div class="bg_alert" style="background-color: #fff;margin: 56% auto;width: 80vw;text-align: center;padding-top: 20px;border-radius: 10px;">
        <div style="color: #000;font-weight: bold;font-size: 18px;">退出登录确认</div>
        <div style="padding: 18px 13px;border-bottom: 1px solid #F4F5F9;font-size: 14px;line-height: 22px;">
          <table style="width: 100%;border-collapse: collapse;">
            <tr>
              <td style="color: #9D9E9F;text-align: center;">确认退出登录？</td>
            </tr>
          </table>
        </div>
        <div style="display: flex;justify-content: space-around;height: 46px;line-height: 46px;">
          <p style="width: 50%; border-right: 1px solid #F4F5F9;color:#6C7380;" @click="qdSureVisi = false">取消</p>
          <p style="width: 50%;color: #739F2F;" @click="qdSure('tc')">确认</p>
        </div>
      </div>
    </div>

    <!-- 注销弹窗 -->
    <div v-if="zxSureVisi" style="position: fixed;top: 0;left: 0; width: 100vw;height: 100vh;background-color: rgba(0, 0, 0, 0.5);">
      <div class="bg_alert" style="background-color: #fff;margin: 56% auto;width: 80vw;text-align: center;padding-top: 20px;border-radius: 10px;">
        <div style="color: #000;font-weight: bold;font-size: 18px;">注销确认</div>
        <div style="padding: 18px 13px;border-bottom: 1px solid #F4F5F9;font-size: 14px;line-height: 22px;">
          <table style="width: 100%;border-collapse: collapse;">
            <tr>
              <td style="color: #9D9E9F;text-align: center;">确认注销账号？</td>
            </tr>
          </table>
        </div>
        <div style="display: flex;justify-content: space-around;height: 46px;line-height: 46px;">
          <p style="width: 50%; border-right: 1px solid #F4F5F9;color:#6C7380;" @click="zxSureVisi = false">取消</p>
          <p style="width: 50%;color: #E81F28;" @click="qdSure('zx')">确认</p>
        </div>
      </div>
    </div>
    <!-- 提醒 -->
    <div v-if="qdSureToastVisi" style="position: fixed;top: 0;left: 0; width: 100vw;height: 100vh;">
      <p style="background-color: #000;color: #fff; margin: 70% auto;width: 80vw;text-align: center;padding: 10px 20px;border-radius: 10px;">
        {{qdSureToastTitle}}
      </p>
    </div>
  </div>
</template>

<script>
export default {
  name: "my",
  data() {
    return {
      qdSureVisi: false,
      zxSureVisi: false,
      qdSureToastVisi: false,
      qdSureToastTitle: "", // 
    };
  },
  methods: {
    goToPage(page) {
      this.$router.push({ name: page });
    },
    goBack() {
      // 返回上一页逻辑
      window.history.back();
    },
    toQd (item) {
      if(item === 'tc'){
        this.qdSureVisi = true
      }
      if(item === 'zx'){
        this.zxSureVisi = true
      }
    },
    qdSure (item) {
      if(item === 'tc'){
        this.qdSureToastVisi = true;
        this.qdSureToastTitle = '退出成功!'
        setTimeout(() => {
          this.qdSureToastVisi = false
          this.Index = -1

          this.qdSureVisi = false;
          this.$router.push({ name: 'index'})
        }, 2000);
       
      }
      if(item === 'zx'){
       this.qdSureToastVisi = true;
        this.qdSureToastTitle = '注销成功!'
        setTimeout(() => {
          this.qdSureToastVisi = false
          this.Index = -1

          this.qdSureVisi = false;
          this.$router.push({ name: 'index'})
        }, 2000);
      }
    },
    toDetail (i) {
      this.$router.push({ name: 'qiangdandetail', params: { i } })
    }
  },
};
</script>

<style scoped>
/* 页面样式 */
.page {
  font-size: 13px;
  background-color: #f4f5f9;
  min-height: 100vh;
}


/* 功能区 */
.function-area {
  background-color: white;
  padding: 10px;
}
/* 头部样式 */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.back-btn {
  position: absolute;
    left: -1em;

  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}
h1 {
  margin: 0;
}

.context {
  font-size: 13px;
  padding: 10px;
  height: 100%;
  background: #f4f5f9;
}

.context {
  font-size: 13px;
  padding: 10px;
  height: 100%;
  background: #f4f5f9;
}

/* 主容器样式 */
.container {
  margin-top: 10px;
  background-color: #ffffff;
  border-radius: 8px;
  padding: 0px 10px;
  margin: 10px;
}

/* 行样式 */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 10px;
}

/* 左侧文本框样式 */
.label {
  color: #666666;
}

/* 右侧文本框样式 */
.value {
  color: #9d9e9f;
}

/* 分割线 */
.divider {
  height: 1px;
  background-color: #f4f5f9;
  width: 100%;
}

/* 第二行头像样式 */
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  margin-right: 5px;
}

/* 右侧内容容器 */
.right {
  display: flex;
  align-items: center;
}

/* 右侧图标样式 */
.icon {
  width: 16px;
  height: 16px;
}

/* 退出 */
.logoff-area {
  margin: 20px;
}
.logoff-button {
  width: 100%;
  color: #e81f28;
  font-size: 16px;
  padding: 16px 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* 弹窗 */
.bg_alert {
  background-image: url('@/assets/xiangmujindu/bg_alert.png');
  background-position: top 0% left 0;
  background-size: 100% 40%;
  background-repeat: no-repeat;
}
</style>
